#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Time       :   22:40
# Author     : Y4
# Site       : 
# File       : 001 进程创建.py
# Software   : PyCharm

from multiprocessing import Process
import os

from time import sleep


def task1():
    while True:
        sleep(1)
        print('这是任务1,---{}---{}'.format(os.getpid(), os.getppid()))  # 这是任务1,---8244---12392


def task2():
    while True:
        sleep(2)
        print('这是任务2,---{}---{}'.format(os.getpid(), os.getppid()))  # 这是任务1,---8244---12392


if __name__ == '__main__':
    print(os.getpid())  # 12392

    # 子进程
    p1 = Process(target=task1, name='任务1')
    p1.start()
    print(p1.name)

    p2 = Process(target=task2, name='任务2')
    p2.start()
    print(p2.name)
